package com.thread.exception;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class ExceptionThread implements Runnable {

	@Override
	public void run() {
		// Thread的run方法是不抛出任何检查型异常(checked
		// exception)的,但是它自身却可能因为一个异常而被终止，导致这个线程的终结。
		throw new RuntimeException();
	}

	public static void main(String[] args) {
		try {
			ExecutorService exec = Executors.newCachedThreadPool();
			exec.execute(new ExceptionThread());
		} catch (RuntimeException e) {
			// 即使使用了try，catch也不会捕获异常
			System.out.println("捕获了异常");
		}
	}

}
